package util

type Equalable interface{
	GetHashCode() int
	Equal(other Equalable) bool
}

func CalculateAddElements(oldSlice []Equalable,newSlice []Equalable) []Equalable {
	addElements := make([]Equalable,0)

	for _,newElement := range newSlice{
		noElement := true
		for _,oldElement := range oldSlice{
			if newElement.Equal(oldElement) {
				noElement = false
				break
			}
		}
		if noElement{
			addElements = append(addElements, newElement)
		}
	}
	return addElements
}

func  CalculateChange(oldSlice []Equalable,newSlice []Equalable)([]Equalable,[]Equalable)  {
	addElements := CalculateAddElements(oldSlice,newSlice)
	removeElementes := CalculateAddElements(newSlice,oldSlice)

	return addElements,removeElementes
}